package com.gxc.service.impl;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author GongXincheng
 * @since 2019-08-23 15:00
 */
@Service
public class ScheduleService {

    private static final ThreadLocal<DateFormat> DATA_FORMAT = ThreadLocal.withInitial(
            () -> new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));

    @Scheduled(cron = "10-20 15-16 15 23 * ?")
    public void schedule() {
        System.out.println(DATA_FORMAT.get().format(new Date()));
    }

}
